<div class="row">
	<div class="span12">
		<div class="page-header">
			<h1 style="display: inline;">
				Questions <small>for <?php echo $this->Html->link($survey['Survey']['name'], array('controller' => 'Surveys', 'action' => 'view', $survey['Survey']['id'])); ?></small>
			</h1>
			<div class="pull-right">
				<?php echo $this->TwitterBootstrap->button_link("<i class='icon-plus icon-white'></i>&nbsp;Add a Question", array('controller' => 'Questions', 'action' => 'add', $survey['Survey']['id']), array('style' => 'success', 'escape' => false)); ?>
				<?php echo $this->TwitterBootstrap->button_link("<i class='icon-list icon-white'></i>&nbsp;Change Question Order", array('controller' => 'Questions', 'action' => 'changeOrder', $survey['Survey']['id']), array('style' => 'info', 'escape' => false)); ?>
			</div>
		</div>
	</div>
</div>
<div class="row">
	<div class="span12">
		<?php if (!empty($questions)): ?>
			<div class="accordion" id="question-accordion">
				<?php foreach ($questions as $question): ?>
					<div class="accordion-group">
						<div class="accordion-heading">
							<a class="accordion-toggle" data-toggle="collapse" data-parent="#question-accordion" href="#q-coll-<?php echo $question['Question']['id']; ?>">
								<strong><?php echo $question['Question']['label']; ?></strong>
								<small><?php echo $question['ConcreteQuestion']->name; ?></small>
							</a>
						</div>
						<div id="q-coll-<?php echo $question['Question']['id']; ?>" class="accordion-body collapse">
							<div class="accordion-inner">
								<div class="row-fluid">
									<div class="span6">
										<dl class="dl-horizontal">
											<dt>Label</dt>
											<dd><?php echo $question['Question']['label']; ?>&nbsp;</dd>

											<dt>Help Text</dt>
											<dd><?php echo $question['Question']['help_text']; ?>&nbsp;</dd>

											<dt>Required</dt>
											<dd><?php echo $question['Question']['required'] ? $this->TwitterBootstrap->label("Yes", 'success') : $this->TwitterBootstrap->label("No", 'important'); ?></dd>

											<?php echo $this->element(sprintf('ConcreteQuestions/View/%s-dl', $question['ConcreteQuestion']->name), array('cq' => $question['ConcreteQuestion'])); ?>
										</dl>
									</div>
									<div class="span6">
										<div class="row-fluid question-actions">
											<div class="span12">
												<?php echo $this->TwitterBootstrap->button_link('Edit this Question', array('controller' => "Questions", 'action' => "edit", $question['Question']['id']), array('style' => 'warning', 'size' => 'mini')); ?>
												<?php echo $this->TwitterBootstrap->button_form('Delete this Question', array('controller' => "Questions", 'action' => "delete", $question['Question']['id']), array('style' => 'danger', 'size' => 'mini'), "REALLY delete this question?"); ?>
											</div>
										</div>

										<div class="row-fluid">
											<div class="span12">
												<h4>Question Preview</h4>
												<?php echo $this->element( sprintf('ConcreteQuestions/Input/%s', $question['ConcreteQuestion']->name), array('cq' => $question['ConcreteQuestion']) ); ?>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				<?php endforeach; ?>
			</div>
		<?php else: ?>
			<p>Define some Questions for your survey using the <strong><span class="text-success">Add a Question</span></strong> button above!</p>
		<?php endif; ?>
	</div>
</div>